//
//  Complex.m
//  oc_练习1
//
//  Created by blue on 16/4/13.
//  Copyright (c) 2016年 csx. All rights reserved.
//

#import "Complex.h"

@implementation Complex

-(void)setReal:(NSInteger)real{
    _real = real;
}
-(void)setImaginary:(NSInteger)imaginary{
    _imaginary = imaginary;
}

-(id)initWithReal:(NSInteger)real andImaginary:(NSInteger)imaginary{
    self = [super init];
    if(self){
        _real = real;
        _imaginary = imaginary;
    }
    return self;
}

-(NSInteger)real{
    return _real;
}
-(NSInteger)imaginary{
    return _imaginary;
}

-(Complex *)addComplex:(Complex *)c1{
    _real = _real + c1.real;
    _imaginary = _imaginary + c1.imaginary;
    return self;
    
}


+(void)addAComplex:(Complex *)c1 andBComplex:(Complex *)c2{
    Complex *c=[[Complex alloc]init];
    NSLog(@"%ld",c1.real+c2.real);
    c.real = c1.real + c2.real;
    c.imaginary = c1.imaginary + c2.imaginary;
    NSLog(@"%ld+%ldi",c.real,c.imaginary);
}

-(void)printComplex{
    NSLog(@"%ld+%ldi",_real,_imaginary);
}

@end
